<template>
  <div>
    <ul>
      <li v-for="(item, index) in myArr" :key="index">
        {{ item }} <button @click="del(index)">删除</button>
      </li>
    </ul>
    <button @click="add">生成</button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      myArr: [2, 4, 6],
    };
  },

  methods: {
    add() {
      let i = parseInt(Math.random() * 100);
      this.myArr.push(i);
    },

    del(index) {
      this.myArr.splice(index, 1);
    },
  },
};
</script>

<style>
</style>